package com.by.controller;

import com.by.entity.ResultBean;
import com.by.ex.BusinessException;
import com.by.ex.ValidateException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * date 2025/2/14 17:52
 * author bjj
 * decoration
 * version 1.0
 * since jdk11
 */
@RestControllerAdvice
public class GlobalExceptionController extends BaseController {
    @ExceptionHandler(com.by.ex.ValidateException.class)
    public ResultBean handlerValidationException(ValidateException e) {
        return fail("验证失败", e.getErrorMap());
    }

    @ExceptionHandler(BusinessException.class)
    public ResultBean handlerBusinessException(BusinessException e) {
        return fail("业务异常", e.getMessage());
    }
}
